package cxf;/**
 * @author XuXiaoK
 * @create 2020-01-20 19:21
 */

import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.client.WebClient;

import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;

/**
 *@Author XiaoKe
 *@Date 2020/1/20 19:21
 *@Description TODO
 */
public class CxfDemo {

    public static void main(String[] args) throws IOException {
        // 创建WebClient
        WebClient client = WebClient.create("http://localhost:8764/hello?name=xiaoke");
        // 获取响应
        Response response = client.get();
        // 获取响应内容
        InputStream entity = (InputStream) response.getEntity();
        String s = IOUtils.readStringFromStream(entity);
        // 输出字符串
        System.out.println(s);
    }
}
